package com.arpa.oms.service;

import com.arpa.oms.domain.dto.OmsOutboundDTO;
import com.arpa.oms.domain.entity.OmsAllocation;
import com.arpa.oms.domain.entity.OmsOutbound;
import com.arpa.oms.domain.vo.OmsOutboundVO;
import com.arpa.oms.domain.vo.OmsSaleReturnVO;
import com.arpa.oms.domain.vo.SaleVO;
import com.arpa.wms.domain.entity.Outbound;
import com.arpa.wms.domain.entity.OutboundItem;
import com.arpa.wms.domain.entity.Putaway;
import com.baomidou.mybatisplus.extension.service.IService;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * OMS出库单 服务类
 * </p>
 *
 * @author LEO
 * @since 2020-11-07
 */
public interface IOmsOutboundService extends IService<OmsOutbound> {

    /**
     * 保存
     * @param entity
     * @return
     */
    @Override
    boolean save(OmsOutbound entity);

    /**
     * 根据code更新实体
     * @param entity
     * @return
     */
    int updateByCode(OmsOutbound entity);

    /**
     * 查询列表
     * @param omsOutboundDTO
     * @return
     */
    List<OmsOutboundVO> queryList(OmsOutboundDTO omsOutboundDTO);

    /**
     * 查询合计,包含总数
     * @param omsOutboundDTO
     * @return
     */
    OmsOutboundVO queryListSum(OmsOutboundDTO omsOutboundDTO);

    /**
     * 根据销售单生成oms出库单
     * @param sale
     */
    void saveBySale(SaleVO sale, Integer omsWmsFlag);

    /**
     * wms端触发生成oms出库单
     * @param sale
     */
    void saveBySaleForWms(SaleVO sale, Outbound wmsOutbound, Map<String, BigDecimal[]> sourceItemOutQuantity);

    /**
     * @description
     * 获取出库单及出库单明细列表
     * @author xuyang
     * @date 2020/11/14 8:02
     * @param code:
     **/
    OmsOutboundVO getVOByCode(String code);

    /**
     * @description
     * 根据销售退货单生成红冲出库单
     * @author xuyang
     * @date 2020/12/14 15:31
     * @param saleReturnVO:
     * @param omsWmsFlag: 0: 直接根据oms销退单生成，出库数量是销退单明细计划数量；
     *                  1： wms更新oms生成，出库数量为销退单明细实际出库数量
     **/
    void saveBySaleReturn(OmsSaleReturnVO saleReturnVO, Integer omsWmsFlag, Putaway putaway);

    void saveByOmsAllocation(OmsAllocation omsAllocation);

    void saveByWmsOutbound(Outbound outbound, List<OutboundItem> outboundItemList);

    /**
     * 根据调拨单生成出库单
     * @param allocation
     * @param outbound
     * @param sourceItemOutQuantity
     */
    void saveByOmsAllocationForWms(OmsAllocation allocation, Outbound outbound, Map<String, BigDecimal[]> sourceItemOutQuantity);
    void saveByOmsAllocationForWmsOutBound(OmsAllocation allocation, Outbound outbound);

    List<Map<String, Object>> outboundCount(String shipmentCode, List<String> warehouseCodes);
}
